<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
 <meta>
  <!-- Stylesheets -->
  <link href="../web.css" type="text/css" rel="stylesheet"></link>
  <link href="../pygmentize.css" type="text/css" rel="stylesheet"></link>
  <title>VLFeat - Documentation - C API</title>
  <link rel="stylesheet" type="text/css" href="../doxygen.css"></style>

  <!-- Scripts-->
  
 </meta>

 <!-- Body Start -->
 <body>
  <div id="header">
   <!-- Google CSE Search Box Begins -->
   <form action="http://www.vlfeat.org/search.html" method="get" id="cse-search-box" enctype="application/x-www-form-urlencoded">
    <div>
     <input type="hidden" name="cx" value="003215582122030917471:oq23albfeam"></input>
     <input type="hidden" name="cof" value="FORID:11"></input>
     <input type="hidden" name="ie" value="UTF-8"></input>
     <input type="text" name="q" size="31"></input>
     <input type="submit" name="sa" value="Search"></input>
    </div>
   </form>
   <script src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en" xml:space="preserve" type="text/javascript"></script>
   <!-- Google CSE Search Box Ends -->
   <h1><a shape="rect" href="../index.html" class="plain"><span id="vlfeat">VLFeat</span><span id="dotorg">.org</span></a></h1>
  </div>
  <div id="headbanner">
   Documentation - C API
  </div>
  <div id="pagebody">
   <div id="sidebar"> <!-- Navigation Start -->
    <ul>
<li><a href="../index.html">Home</a>
</li>
<li><a href="../download.html">Download</a>
</li>
<li><a href="../doc.html">Documentation</a>
<ul>
<li><a href="../mdoc/mdoc.html">Matlab API</a>
</li>
<li><a href="index.html" class='active' >C API</a>
</li>
<li><a href="../man/man.html">Man pages</a>
</li>
</ul></li>
<li><a href="../overview/tut.html">Tutorials</a>
</li>
<li><a href="../applications/apps.html">Applications</a>
</li>
</ul>

   </div> <!-- sidebar -->
   <div id="content">
    
    <link rel="stylesheet" type="text/css" href="../doxygen.css"></style>
    <div class="doxygen">
<div>
<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#define-members">Defines</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">qsort-def.h File Reference</div>  </div>
</div>
<div class="contents">

<p>QSort preprocessor metaprogram.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;<a class="el" href="host_8h.html">host.h</a>&quot;</code><br/>
<code>#include &lt;assert.h&gt;</code><br/>
</div><table class="memberdecls">
<tr><td colspan="2"><h2><a name="define-members"></a>
Defines</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsort-def_8h.html#a09b2946a2aa460a9d33a78f46056059c">VL_QSORT_array</a>&#160;&#160;&#160;VL_QSORT_type*</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsort-def_8h.html#a6bc1350759ef49165982d85fe1996be3">VL_QSORT_prefix</a>&#160;&#160;&#160;QSortPrefix</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsort-def_8h.html#aa7bbcd78393c03275c0e3d55c1decdb0">VL_QSORT_type</a>&#160;&#160;&#160;QSortType</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsort-def_8h.html#a09b2946a2aa460a9d33a78f46056059c">VL_QSORT_array</a>&#160;&#160;&#160;QSortType*</td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">VL_QSORT_type&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsort-def_8h.html#a846b82fcc68f6bb540da6243d2670ed1">VL_QSORT_cmp</a> (VL_QSORT_array_const array, <a class="el" href="host_8h.html#ac13bd3cc913e1da576e189a3ec8d66fc">vl_uindex</a> indexA, <a class="el" href="host_8h.html#ac13bd3cc913e1da576e189a3ec8d66fc">vl_uindex</a> indexB)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Compare two array elements.  <a href="#a846b82fcc68f6bb540da6243d2670ed1"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsort-def_8h.html#ac7face14222e47cac7d730925637ac91">VL_QSORT_swap</a> (VL_QSORT_array array, <a class="el" href="host_8h.html#ac13bd3cc913e1da576e189a3ec8d66fc">vl_uindex</a> indexA, <a class="el" href="host_8h.html#ac13bd3cc913e1da576e189a3ec8d66fc">vl_uindex</a> indexB)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Swap two array elements.  <a href="#ac7face14222e47cac7d730925637ac91"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsort-def_8h.html#aa91794fadc74f98458f58a22cd0bd6ae">VL_QSORT_sort_recursive</a> (VL_QSORT_array array, <a class="el" href="host_8h.html#ac13bd3cc913e1da576e189a3ec8d66fc">vl_uindex</a> begin, <a class="el" href="host_8h.html#ac13bd3cc913e1da576e189a3ec8d66fc">vl_uindex</a> end)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Sort portion of an array using quicksort.  <a href="#aa91794fadc74f98458f58a22cd0bd6ae"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qsort-def_8h.html#a11be07172455010601a417058008ffa4">VL_QSORT_sort</a> (VL_QSORT_array array, <a class="el" href="host_8h.html#a0ee26101458c663510d620e3ee7e2555">vl_size</a> size)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Sort array using quicksort.  <a href="#a11be07172455010601a417058008ffa4"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><dl class="author"><dt><b>Author:</b></dt><dd>Andrea Vedaldi</dd></dl>
<h2><a class="anchor" id="qsort-def-overview"></a>
Overview</h2>
<p><a class="el" href="qsort-def_8h.html">qsort-def.h</a> is a metaprogram to define specialized instances of the quick-sort algorithm.</p>
<h2><a class="anchor" id="qsort-def-usage"></a>
Usage</h2>
<p><a class="el" href="qsort-def_8h.html">qsort-def.h</a> is used to define a specialization of the <a class="el" href="qsort-def_8h.html#a11be07172455010601a417058008ffa4" title="Sort array using quicksort.">VL_QSORT_sort</a> function that operatoes on a given type of array. For instance the code</p>
<div class="fragment"><pre class="fragment"><span class="preprocessor"> #define VL_QSORT_type float</span>
<span class="preprocessor"></span><span class="preprocessor"> #define VL_QSORT_prefix my_qsort</span>
<span class="preprocessor"> #include &lt;vl/qsort-def.h&gt;</span>
</pre></div><p>defines a function <code>my_qsort_sort</code> that operates on an array of floats.</p>
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000001">Todo:</a></b></dt><dd>large array compatibility. </dd></dl>
</div><hr/><h2>Define Documentation</h2>
<a class="anchor" id="a09b2946a2aa460a9d33a78f46056059c"></a><!-- doxytag: member="qsort&#45;def.h::VL_QSORT_array" ref="a09b2946a2aa460a9d33a78f46056059c" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define VL_QSORT_array&#160;&#160;&#160;VL_QSORT_type*</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Data type of the qsort container </p>

</div>
</div>
<a class="anchor" id="a09b2946a2aa460a9d33a78f46056059c"></a><!-- doxytag: member="qsort&#45;def.h::VL_QSORT_array" ref="a09b2946a2aa460a9d33a78f46056059c" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define VL_QSORT_array&#160;&#160;&#160;QSortType*</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Data type of the qsort container </p>

</div>
</div>
<a class="anchor" id="a6bc1350759ef49165982d85fe1996be3"></a><!-- doxytag: member="qsort&#45;def.h::VL_QSORT_prefix" ref="a6bc1350759ef49165982d85fe1996be3" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define VL_QSORT_prefix&#160;&#160;&#160;QSortPrefix</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Prefix of the qsort functions </p>

</div>
</div>
<a class="anchor" id="aa7bbcd78393c03275c0e3d55c1decdb0"></a><!-- doxytag: member="qsort&#45;def.h::VL_QSORT_type" ref="aa7bbcd78393c03275c0e3d55c1decdb0" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define VL_QSORT_type&#160;&#160;&#160;QSortType</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Data type of the qsort elements </p>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="a846b82fcc68f6bb540da6243d2670ed1"></a><!-- doxytag: member="qsort&#45;def.h::VL_QSORT_cmp" ref="a846b82fcc68f6bb540da6243d2670ed1" args="(VL_QSORT_array_const array, vl_uindex indexA, vl_uindex indexB)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">VL_QSORT_type VL_QSORT_cmp </td>
          <td>(</td>
          <td class="paramtype">VL_QSORT_array_const&#160;</td>
          <td class="paramname"><em>array</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="host_8h.html#ac13bd3cc913e1da576e189a3ec8d66fc">vl_uindex</a>&#160;</td>
          <td class="paramname"><em>indexA</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="host_8h.html#ac13bd3cc913e1da576e189a3ec8d66fc">vl_uindex</a>&#160;</td>
          <td class="paramname"><em>indexB</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">array</td><td>qsort array. </td></tr>
    <tr><td class="paramname">indexA</td><td>index of the first element <code>A</code> to compare. </td></tr>
    <tr><td class="paramname">indexB</td><td>index of the second element <code>B</code> to comapre. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>a negative number if <code>A&lt;B</code>, 0 if <code>A==B</code>, and a positive number if if <code>A&gt;B</code>. </dd></dl>

</div>
</div>
<a class="anchor" id="a11be07172455010601a417058008ffa4"></a><!-- doxytag: member="qsort&#45;def.h::VL_QSORT_sort" ref="a11be07172455010601a417058008ffa4" args="(VL_QSORT_array array, vl_size size)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void VL_QSORT_sort </td>
          <td>(</td>
          <td class="paramtype">VL_QSORT_array&#160;</td>
          <td class="paramname"><em>array</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="host_8h.html#a0ee26101458c663510d620e3ee7e2555">vl_size</a>&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">array</td><td>(in/out) pointer to the array. </td></tr>
    <tr><td class="paramname">size</td><td>size of the array.</td></tr>
  </table>
  </dd>
</dl>
<p>The function sorts the array using quick-sort. </p>

</div>
</div>
<a class="anchor" id="aa91794fadc74f98458f58a22cd0bd6ae"></a><!-- doxytag: member="qsort&#45;def.h::VL_QSORT_sort_recursive" ref="aa91794fadc74f98458f58a22cd0bd6ae" args="(VL_QSORT_array array, vl_uindex begin, vl_uindex end)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void VL_QSORT_sort_recursive </td>
          <td>(</td>
          <td class="paramtype">VL_QSORT_array&#160;</td>
          <td class="paramname"><em>array</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="host_8h.html#ac13bd3cc913e1da576e189a3ec8d66fc">vl_uindex</a>&#160;</td>
          <td class="paramname"><em>begin</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="host_8h.html#ac13bd3cc913e1da576e189a3ec8d66fc">vl_uindex</a>&#160;</td>
          <td class="paramname"><em>end</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">array</td><td>(in/out) pointer to the array. </td></tr>
    <tr><td class="paramname">begin</td><td>first element of the array portion. </td></tr>
    <tr><td class="paramname">end</td><td>last element of the array portion.</td></tr>
  </table>
  </dd>
</dl>
<p>The function sorts the array using quick-sort. Note that <code>begin</code> must be not larger than <code>end</code>. </p>

</div>
</div>
<a class="anchor" id="ac7face14222e47cac7d730925637ac91"></a><!-- doxytag: member="qsort&#45;def.h::VL_QSORT_swap" ref="ac7face14222e47cac7d730925637ac91" args="(VL_QSORT_array array, vl_uindex indexA, vl_uindex indexB)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void VL_QSORT_swap </td>
          <td>(</td>
          <td class="paramtype">VL_QSORT_array&#160;</td>
          <td class="paramname"><em>array</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="host_8h.html#ac13bd3cc913e1da576e189a3ec8d66fc">vl_uindex</a>&#160;</td>
          <td class="paramname"><em>indexA</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="host_8h.html#ac13bd3cc913e1da576e189a3ec8d66fc">vl_uindex</a>&#160;</td>
          <td class="paramname"><em>indexB</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">array</td><td>qsort array. </td></tr>
    <tr><td class="paramname">indexA</td><td>index of the first element to swap. </td></tr>
    <tr><td class="paramname">indexB</td><td>index of the second element to swap.</td></tr>
  </table>
  </dd>
</dl>
<p>The function swaps the two elements <em>a</em> and @ b. The function uses a temporary element of type <a class="el" href="qsort-def_8h.html#aa7bbcd78393c03275c0e3d55c1decdb0">VL_QSORT_type</a> and the copy operator <code>=</code>. </p>

</div>
</div>
</div>
     <!-- Doc Here -->
    </div>
   
   </div>
   <div class="clear">&nbsp;</div>
  </div> <!-- pagebody -->
  <div id="footer">
   &copy; 2007-12 Andrea Vedaldi and Brian Fulkerson
  </div> <!-- footer -->

  <!-- Google Analytics Begins -->
  <script xml:space="preserve" type="text/javascript">
   //<![CDATA[
    var localre = /vlfeat.org/;
    if(document.location.host.search(localre) != -1)
    {
   var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
   document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
   }
   //]]>
  </script>
  <script xml:space="preserve" type="text/javascript">
    //<![CDATA[
    var localre = /vlfeat.org/;
    if(document.location.host.search(localre) != -1)
    {

   try {
   var pageTracker = _gat._getTracker("UA-4936091-2");
   pageTracker._trackPageview();
   } catch(err) {}

   }
   //]]>
  </script>
  <!-- Google Analytics Ends -->
 </body>
</html>

 
